<head>
	<script>
	function write_save()
	{
	    var f = document.bWriteForm;
	
	
	    if(f.b_title.value == ""){
	        alert("글제목을 입력해 주세요.");
	        return false;
	    }
	
	    if(f.b_contents.value == ""){
	        alert("글내용을 입력해 주세요.");
	        return false;
	    }
	
	    f.submit();
	
	}
</script>
</head>
<?
	include ("./include.php");
	
	if(!$_SESSION[user_id]){
	    ?>
	    <script>
	        alert("로그인 하셔야 합니다.");
	        location.replace("board_login.php");
	    </script>
	    <?
	}
	
	$sql = "select * from tb_board where b_idx = '".$_GET[b_idx]."'";
	$result = sql_querry($sql);
	$data = mysql_fetch_array($result);
	
	if(!$data[b_idx]){
	    ?>
	    <script>
	        alert("존재하지 않는 글입니다.");
	        history.back();
	    </script>
	    <?
	}
	
	if($data[m_id] != $_SESSION[user_id]){
	    ?>
	    <script>
	        alert("본인의 글이 아닙니다.");
	        history.back();
	    </script>
	    <?
	}

?>
<br/>
<table style="width:1000px;height:50px;border:5px #CCCCCC solid;">
    <tr>
        <td align="center" valign="middle" style="font-zise:15px;font-weight:bold;">글수정</td>
    </tr>
</table>
<br/>
<form name="bWriteForm" method="post" action="./board_modify_save.php" style="margin:0px;">
<input type="hidden" name="b_idx" value="<?=$data[b_idx]?>">
<table style="width:1000px;height:50px;border:0px;">
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">글제목</td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="b_title" style="width:780px;" value="<?=$data[b_title]?>"></td>
    </tr>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:200px;background-color:#CCCCCC;">글내용</td>
        <td align="left" valign="middle" style="width:800px;height:200px;">
        <textarea name="b_contents" style="width:800px;height:200px;"><?=$data[b_contents]?></textarea>
        </td>
    </tr>
    <tr>
        <td align="center" valign="middle" colspan="2"><input type="button" value=" 글수정 " onClick="write_save();">&nbsp;&nbsp;&nbsp;<input type="button" value=" 뒤로가기 " onClick="history.back();"></td>
    </tr>
</table>
</form>